const express = require('express');
const router = express.Router();
const { getArticleList, getArticleDetail, addArticle, updateArticle, deleteArticle } = require('../controller/blog');
const { SuccessMessageModel, ErrorMessageModel } = require('../model/reModel');
const loginCheck = require('../middleware/loginCheck');

/**
 * 文章列表
 */
router.post('/articleList', (req, res, next) => {
  const { id, keyWord } = req.query;
  console.log('author, keyword', req.query, req.body, req.params);
  let result = getArticleList(id, keyWord);
  return result.then( listData => {
    res.json(new SuccessMessageModel(listData, '查询成功'));
  })
});

/**
 * 文章详情
 */
router.post('/articleDetail', (req, res, next) => {
  res.send('respond with router /list');
});

/**
 * 评论文章
 */
router.post('/addComments', (req, res, next) => {
  res.send('respond with router /list');
});

/**
 * 查询当前文章的评论
 */
router.post('/commentsList', (req, res, next) => {
  res.send('respond with router /list');
});


module.exports = router;
